<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Diagnostics" %>
<Script runat="server">
  Public Sub Page_Load(sender As Object,  _
	e As EventArgs)
    Dim connection As SqlConnection
    Dim command As SqlCommand
    Dim reader As SqlDataReader
    Dim sqlSelect As String
    Dim strConn = _
	ConfigurationSettings.appSettings("conn")
    sqlSelect="Select * From tblSubCategory"
    sqlSelect +=" where SubCateID>10"    
    connection = New SqlConnection(strConn)
    command = _
	New SqlCommand(sqlSelect, connection)
    connection.Open()
    reader = command.ExecuteReader()
    datagrid1.DataSource = reader
    datagrid1.DataBind()
    connection.Close()
  End Sub
  Sub Page_Error(Sender As Object, E AS EventArgs)
	Dim err As String
	err="Error in: " & Request.Url.ToString() 
	err+="<br />Stack Trace Below:<br />" & _
	Server.GetlastError().toString()
	Server.ClearError()
	Try
		WriteToEventLog("ErrorPageError"+ _
		DateTime.Now().ToString(),err)
	Catch objError As Exception
		outError.innerHTML = _
		"<b>* Error while " & _
		"accessing data</b>.<br />" _
          		& objError.Message & "<br />" & _
		objError.Source
      		Exit Sub  
	End Try
  End Sub
  Sub WriteToEventLog(ByVal LogName As String, _
	ByVal Message As String)
	If (Not EventLog.SourceExists(LogName)) Then
		EventLog.CreateEventSource(LogName,LogName)
	End If
	Dim Log As New EventLog
	Log.Source=LogName
	Log.WriteEntry(Message, EventLogEntryType.Error)
  End Sub
</Script>
<div id="outError" runat="server">&nbsp;</div>
<asp:datagrid id="datagrid1" runat="server" />
